package ${package}.controller.page.${moduleName};

import cn.gooday.jsh.service.common.dto.RestControllerResult;
import cn.gooday.jsh.service.common.mybatis.YlhPageInfo;
import javax.annotation.Resource;
import ${package}.api.page.${moduleName}.${ClassName}Api;
import ${package}.dto.api.${moduleName}.Get${ClassName}ParamsDto;
import ${package}.dto.api.${moduleName}.Get${ClassName}ResultDto;
import ${package}.dto.api.${moduleName}.Save${ClassName}ParamsDto;
import ${package}.service.${moduleName}.${ClassName}Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * ${functionName}相关API.
 */
@RestController
public class ${ClassName}Controller
    implements ${ClassName}Api {

  @Resource
  private ${ClassName}Service
      ${className}Service;

  @Override
  public RestControllerResult
      <YlhPageInfo<Get${ClassName}ResultDto>>
      query${ClassName}ListByCondition(
      @RequestBody Get${ClassName}ParamsDto paramsDto) {
    YlhPageInfo<Get${ClassName}ResultDto> resultDtoYlhPageInfo =
        ${className}Service
        .query${ClassName}ListByCondition(paramsDto);
    return RestControllerResult.success(resultDtoYlhPageInfo);
  }

  /**
   * .
   **/
  public RestControllerResult<Get${ClassName}ResultDto>
      get${ClassName}ById(Integer id) {
    RestControllerResult<Get${ClassName}ResultDto> result =
        new RestControllerResult();
    Get${ClassName}ResultDto
        ${className}ResultDto =
            ${className}Service
              .get${ClassName}ById(id);
    result.setSuccess(true);
    result.setData(${className}ResultDto);
    return result;
  }

  /**
  * .
  **/
  public RestControllerResult<Get${ClassName}ResultDto>
      add${ClassName}(
      @RequestBody Save${ClassName}ParamsDto paramsDto) {
    ${className}Service
        .add${ClassName}(paramsDto);
    return RestControllerResult.success(null);
  }

  /**
  * .
  **/
  public RestControllerResult<Get${ClassName}ResultDto>
      update${ClassName}(
      @RequestBody Save${ClassName}ParamsDto paramsDto) {
    ${className}Service
        .update${ClassName}(paramsDto);
    return RestControllerResult.success(null);
  }

  @Override
  public RestControllerResult<Boolean> delete${ClassName}ById(Integer id) {
    return ${className}Service
        .delete${ClassName}ById(id);
  }

  @Override
  public RestControllerResult<Integer>
      change${ClassName}StatusById(Integer id, Integer status) {
    return RestControllerResult
        .success(
            ${className}Service
                .change${ClassName}StatusById(id, status));
  }
}